/*
 * @Author: szx
 * @Date: 2021-10-26 10:25:46
 * @LastEditTime: 2021-10-26 11:06:23
 * @Description:
 * @FilePath: \leetcode\496\496.cpp
 */
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

class Solution {
   public:
    vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {
        vector<int> v;
        for (int& i : nums1) {
            bool flag = false;
            int res = -1;
            for (int& j : nums2) {
                // cout << i << " " << j << endl;
                if (i == j) {
                    flag = true;
                } else if (i < j && flag == true) {
                    res = j;
                    break;
                }
            }
            v.push_back(res);
        }
        return v;
    }
};
int main() {
    vector<int> nums1 = {3, 1, 5, 7, 9, 2, 6};
    vector<int> nums2 = {1, 2, 3, 5, 6, 7, 9, 11};

    Solution s;
    vector<int> v;
    v = s.nextGreaterElement(nums1, nums2);
    for (int& i : v) {
        cout << i << endl;
    }
}